import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/special_list/process_nodes_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/closure/closure_appointment_entity.dart';
import 'package:get/get.dart';

class ReviewDetailsController extends GetxController {
  // 详情 0: 人员   1 || 2: 车辆
  int type = Get.arguments['type'] as int;

  // 详情
  ClosureAppointmentEntity item = Get.arguments['item'] as ClosureAppointmentEntity;

  // 审批流程数据
  List<ProcessNodesEntity>? nodeList;

  @override
  void onInit() {
    super.onInit();
    // 初始化数据
    initData();
  }

  /// 初始化审批流程数据
  Future<void> initData() async {
    // 获取审批流程数据
    final res = await HttpUtil().generateGetRequest<List<ProcessNodesEntity>>(
      Interface.queryNodeData,
      queryParameters: {'id': item.id},
    ).execute();

    res.onSuccess((result) {
      if (result.data != null) {
        nodeList = result.data!;
        update();
      }
    });
  }
}
